import http from '@/http';

const url = '/api/UserSystem/article';

// 资讯文章 列表
export async function getInformationArticleList(options = {}) {
  return await http.request('get', url, options).then(res => {
    if (!options.waitingMask) {
      http.tip(res);
    }
    return res;
  });
}
// 资讯文章 新增
export async function addInformationArticle(options = {}) {
  return await http.request('post', url, options).then(res => {
    res.code == 200 && (res.message = '新增成功');
    if (!options.waitingMask) {
      http.tip(res);
    }
    return res;
  });
}
// 资讯文章 修改
export async function editInformationArticle(id, options = {}) {
  return await http.request('put', `${ url }/${ id }`, options).then(res => {
    res.code == 200 && (res.message = '修改成功');
    if (!options.waitingMask) {
      http.tip(res);
    }
    return res;
  });
}
// 资讯文章 查看
export async function getInformationArticleDetail(id, options = {}) {
  return await http.request('get', `${ url }/${ id }`, options).then(res => {
    if (!options.waitingMask) {
      http.tip(res);
    }
    return res;
  });
}
// 资讯文章 删除
export async function deleteInformationArticle(id, options = {}) {
  return await http.request('delete', `${ url }/${ id }`, options).then(res => {
    res.code == 200 && (res.message = '删除成功');
    if (!options.waitingMask) {
      http.tip(res);
    }
    return res;
  });
}
// 资讯文章 修改状态
export async function editInformationArticleState(id, options = {}) {
  return await http.request('put', `${ url }/state/${ id }`, options).then(res => {
    res.code == 200 && (res.message = '修改成功');
    if (!options.waitingMask) {
      http.tip(res);
    }
    return res;
  });
}
